import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd/message';
export interface Person {
  key: string;
  name: string;
  status: number;
  note: string;
}
@Component({
  selector: 'app-roles',
  templateUrl: './roles.component.html',
  styleUrls: ['./roles.component.scss']
})
export class RolesComponent implements OnInit {
  validateForm!: FormGroup
  @ViewChild('handleOpen')
  listOfData: Person[] = [
    {
      key: '1',
      name: 'John Brown',
      status: 32,
      note: 'admin'
    }
  ]
  constructor(private nzMessageService: NzMessageService, private fb: FormBuilder) { }
  // 删除取消和确认
  cancel(): void {
    this.nzMessageService.info('click cancel');
  }
  confirm(e: string): void {
    
    this.nzMessageService.success('success');

  }
  handleRest() {
    this.validateForm.reset()
  }
  handleSearch() {
    if (this.validateForm.valid) {
      console.log('submit', this.validateForm.value);
      // this.isVisible = false
      // this.isOkLoading = false
    } else {
      Object.values(this.validateForm.controls).forEach(control => {
        if (control.invalid) {
          control.markAsDirty();
          control.updateValueAndValidity({ onlySelf: true });
        }
      });
    }
  }
  ngOnInit(): void {
    this.validateForm = this.fb.group({
      name: [null],
      status: [null],
    });
  }

}
